package zoo.member.admin.validator;


import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import zoo.member.admin.domain.AdminCommand;

public class AdminLoginValidator implements Validator{
	
	@Override
	public boolean supports(Class<?> c) {
		return AdminCommand.class.isAssignableFrom(c);
	}

	@Override
	public void validate(Object command, Errors errors) {
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "ma_name", "required");
		ValidationUtils.rejectIfEmptyOrWhitespace(errors, "ma_passwd", "required");
		
	/*	AdminCommand login = (AdminCommand)command;
		if(errors.hasErrors())
		{
			return;
		}
		
		if(!checkID(login.getMa_name()))
		{
			errors.rejectValue("ma_name", "invalidId");
		}
		else
		{
			if(!checkPassword(login.getMa_passwd()))
			{
				errors.rejectValue("ma_passwd", "invalidPassword");
			}
		}
	
	}
	
	private boolean checkID(String id)
	{
		
	}
	
	private boolean checkPassword(String password)
	{
		return "1234".equals(password);
	}*/
	}	
}
